package net.lab1024.sa.admin.module.cfs.controller;

import cn.hutool.extra.spring.SpringUtil;
import net.lab1024.sa.admin.module.cfs.dao.CfsDataNbUsermonitorinfoDao;
import net.lab1024.sa.admin.module.cfs.domain.form.CfsDataNbUsermonitorinfoAddForm;
import net.lab1024.sa.admin.module.cfs.domain.form.CfsDataNbUsermonitorinfoQueryForm;
import net.lab1024.sa.admin.module.cfs.domain.form.CfsDataNbUsermonitorinfoUpdateForm;
import net.lab1024.sa.admin.module.cfs.domain.vo.CfsDataNbUsermonitorinfoVO;
import net.lab1024.sa.admin.module.cfs.service.CfsDataNbUsermonitorinfoService;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.common.elk.LogToELK;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;

/**
 * 联网设备NB类型表 Controller
 *
 * @Author cfsjiazy
 * @Date 2025-09-15 09:35:31
 * @Copyright  
 */

@RestController
@Tag(name = "联网设备NB类型表")
public class CfsDataNbUsermonitorinfoController {

    @Resource
    private CfsDataNbUsermonitorinfoService cfsDataNbUsermonitorinfoService;


    @PostMapping("/cfsDataNbUsermonitorinfo/test")
    @NoNeedLogin
    @LogToELK("测试NB")
    public ResponseDTO test(){
        return ResponseDTO.ok();
    }

    @Operation(summary = "分页查询 @author cfsjiazy")
    @PostMapping("/cfsDataNbUsermonitorinfo/queryPage")
    @SaCheckPermission("cfsDataNbUsermonitorinfo:query")
    public ResponseDTO<PageResult<CfsDataNbUsermonitorinfoVO>> queryPage(@RequestBody @Valid CfsDataNbUsermonitorinfoQueryForm queryForm) {
        return ResponseDTO.ok(cfsDataNbUsermonitorinfoService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author cfsjiazy")
    @PostMapping("/cfsDataNbUsermonitorinfo/add")
    @SaCheckPermission("cfsDataNbUsermonitorinfo:add")
    public ResponseDTO<String> add(@RequestBody @Valid CfsDataNbUsermonitorinfoAddForm addForm) {
        return cfsDataNbUsermonitorinfoService.add(addForm);
    }

    @Operation(summary = "更新 @author cfsjiazy")
    @PostMapping("/cfsDataNbUsermonitorinfo/update")
    @SaCheckPermission("cfsDataNbUsermonitorinfo:update")
    public ResponseDTO<String> update(@RequestBody @Valid CfsDataNbUsermonitorinfoUpdateForm updateForm) {
        return cfsDataNbUsermonitorinfoService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author cfsjiazy")
    @PostMapping("/cfsDataNbUsermonitorinfo/batchDelete")
    @SaCheckPermission("cfsDataNbUsermonitorinfo:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return cfsDataNbUsermonitorinfoService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author cfsjiazy")
    @GetMapping("/cfsDataNbUsermonitorinfo/delete/{id}")
    @SaCheckPermission("cfsDataNbUsermonitorinfo:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return cfsDataNbUsermonitorinfoService.delete(id);
    }

    @NoNeedLogin
    @GetMapping("/cfsDataNbUsermonitorinfo/delete/test11")
    public void test11() {
        CfsDataNbUsermonitorinfoDao cfsDataNbUsermonitorinfoDao = SpringUtil.getBean(CfsDataNbUsermonitorinfoDao.class);
        System.out.println("----------------------- 测试成功 -----------------------");
        String[] ids = "1,2,ds@ccf,".split(",");
        int i = cfsDataNbUsermonitorinfoDao.deleteBatchIds(Arrays.asList(ids));
        System.out.println("删除了" + i + "条数据");
    }
}
